﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Numeric;

namespace Game
{
    class Battle
    {
        public static Random rand = new Random();
        public static double MeleeDmg(double aAttack, double dDefence, double SkillDmg)
        {
            double AMulti;            
            double DMulti;
            double AMultix;
            double DMultix;
            #region AMulti & DMulti
            if(aAttack < dDefence)
            {
                DMulti = 1.2;
                AMulti = 1;
            }
            else
            {
                DMulti = 1;
                AMulti = 1.2;
            }
            #endregion
            double MultiaAttack = aAttack * AMulti;
            double MultidDefence = dDefence * DMulti;            
            #region AMultix & DMultix
            if ((aAttack - dDefence) < 100)
            {
                AMultix = 1;
            }
            if ((aAttack / 2) > dDefence)
            {
                AMultix = 2;
            }
            if ((aAttack / 3) > dDefence)
            {
                AMultix = 3;
            }
            if ((aAttack / 4) > dDefence)
            {
                AMultix = 4;
            }
            else
            {
                AMultix = 1;
            }
            if ((dDefence - aAttack) < 100)
            {
                DMultix = 1;
            }
            if ((dDefence / 2) > aAttack)
            {
                DMultix = 2;
            }
            if ((dDefence / 3) > aAttack)
            {
                DMultix = 3;
            }
            if ((dDefence / 4) > aAttack)
            {
                DMultix = 4;
            }
            else
            {
                DMultix = 1;
            }
            #endregion
            MultiaAttack = MultiaAttack * AMultix;
            MultidDefence = MultidDefence * DMultix;
            double minDmg = aAttack - dDefence;
            if (minDmg < 0)
            {
                minDmg = 0;
            }
            double maxDmg = MultiaAttack - MultidDefence;
            if (maxDmg < 0)
            {
                maxDmg = 0;
            }
            int PlusDmg = rand.Next((int)minDmg, (int)maxDmg);
            double Dmg = SkillDmg + PlusDmg;
            return Dmg;

        }
        public static double MagicDmg(double aMAttack, double dMDefence, double SpellDmg)
        {
            double MAMulti;
            double MDMulti;
            double MAMultix;
            double MDMultix;
            #region MAMulti & MDMulti
            if (aMAttack < dMDefence)
            {
                MDMulti = 1.2;
                MAMulti = 1;
            }
            else
            {
                MDMulti = 1;
                MAMulti = 1.2;
            }
            #endregion
            double MultiaMAttack = aMAttack * MAMulti;
            double MultidMDefence = dMDefence * MDMulti;
            #region MAMultix & MDMultix
            if ((aMAttack - dMDefence) < 100)
            {
                MAMultix = 1;
            }
            if ((aMAttack / 2) > dMDefence)
            {
                MAMultix = 2;
            }
            if ((aMAttack / 3) > dMDefence)
            {
                MAMultix = 3;
            }
            if ((aMAttack / 4) > dMDefence)
            {
                MAMultix = 4;
            }
            else
            {
                MAMultix = 1;
            }
            if ((dMDefence - aMAttack) < 100)
            {
                MDMultix = 1;
            }
            if ((dMDefence / 2) > aMAttack)
            {
                MDMultix = 2;
            }
            if ((dMDefence / 3) > aMAttack)
            {
                MDMultix = 3;
            }
            if ((dMDefence / 4) > aMAttack)
            {
                MDMultix = 4;
            }
            else
            {
                MDMultix = 1;
            }
            #endregion
            MultiaMAttack = MultiaMAttack * MAMultix;
            MultidMDefence = MultidMDefence * MDMultix;
            double minDmg = aMAttack - dMDefence;
            if (minDmg < 0)
            {
                minDmg = 0;
            }
            double maxDmg = MultiaMAttack - MultidMDefence;
            if (maxDmg < 0)
            {
                maxDmg = 0;
            }
            int PlusDmg = rand.Next((int)minDmg, (int)maxDmg);
            double Dmg = SpellDmg + PlusDmg;
            return Dmg;
        }
    }
}
